package com.jiuyun.auth.dao.impl;

import com.jiuyun.auth.dao.UserDao;
import com.jiuyun.auth.entity.User;
import com.jiuyun.auth.util.AliPool;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;

import java.sql.Connection;
import java.sql.SQLException;

public class UserDaoImpl implements UserDao {

    QueryRunner runner = new QueryRunner();

    @Override
    public User login(String name, String pass) throws SQLException {
        String sql="select * from user where uname=? and upass=?";
        Connection conn = AliPool.getConn();
        User user = runner.query(conn,sql,new BeanHandler<User>(User.class),name,pass);
        conn.close();
        return user;
    }
}
